//package com.mediacloud.app.newsmodule.activity
//
//import android.os.Bundle
//import android.util.Log
//import android.view.View
//import android.view.ViewGroup
//import android.widget.ImageView
//import android.widget.LinearLayout
//import android.widget.TextView
//import com.mediacloud.app.SdkRun
//import com.mediacloud.app.assembly.util.GlideUtils
//import com.mediacloud.app.assembly.views.BadgeView
//import com.mediacloud.app.assembly.views.ImageButtonX
//import com.mediacloud.app.assembly.views.LikeBadgeView
//import com.mediacloud.app.model.news.ArticleItem
//import com.mediacloud.app.newsmodule.R
//import com.mediacloud.app.newsmodule.addnewslike.LikeRefreshUtils.getLikeStatus
//import com.mediacloud.app.newsmodule.addnewslike.p.NewsLikePresenter
//import com.mediacloud.app.reslib.config.NewsDetailStyleConfig
//import com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig
//import com.pdmi.module_uar.http.UarStatisticsUtils
//import java.util.*
//
//abstract class StyleSetActivity_备份啊 : HandleDataCollectActivity() {
//    var titleBarIsOpen = true
//
//    //顶部那一排按钮的根布局
//    var bottomBarLayout: ViewGroup? = null
//
//    //底部的返回按钮
//    var bottomBack: View? = null
//
//    //评论框
//    var tvLetmeSay: TextView? = null
//
//    //收藏
//    var bottomCollectionBtn: ImageButtonX? = null
//
//    //分享
//    var bottomShareView: View? = null
//
//    //评论图标
//    var commentBadgeView: BadgeView? = null
//
//    //点赞
//    var likeBadgeView: LikeBadgeView? = null
//
//    // 按钮的配置项
//    lateinit var newsDetailStyleConfig: NewsDetailStyleConfig
//
//    var newsLikePresenter: NewsLikePresenter? = null
//    override fun onCreate(savedInstanceState: Bundle?) {
//        super.onCreate(savedInstanceState)
//        newsDetailStyleConfig = AppFactoryGlobalConfig.getAppServerConfigInfo(this).newsDetailConfig
//        if (openTitleBarSetting()) {
//            toggleTitleBar(newsDetailStyleConfig.isShowTopBar)
//        }
//        bottomBarLayout = findViewById(R.id.linear_news_bottom_back_bar)
//        if (newsDetailStyleConfig.linkedHashSet.size == 0 && titleBarIsOpen) {
//            bottomBarLayout?.visibility = View.GONE
//        }
//        bottomBack = bottomBarLayout?.findViewById(R.id.view_bottom_back)
//        commentBadgeView = bottomBarLayout?.findViewById(R.id.commentBadgeView)
//        bottomShareView = bottomBarLayout?.findViewById(R.id.image_bottom_share)
//        bottomCollectionBtn = bottomBarLayout?.findViewById(R.id.image_bottom_collect)
//        tvLetmeSay = bottomBarLayout?.findViewById(R.id.tv_letme_say)
//        likeBadgeView = bottomBarLayout?.findViewById(R.id.likeBadgeView)
//        bottomBack?.setOnClickListener { finish() }
//        bottomCollectionBtn?.setOnClickListener { v: View? ->
//            if (pageInfoBean != null) SdkRun.addTask { UarStatisticsUtils.statisticsBrowseMark(pageInfoBean) }
//            onCollectClick()
//        }
//        bottomShareView?.setOnClickListener { v: View? -> onShareClick() }
//        commentBadgeView?.setOnClickListener { v: View? -> onCommentClick() }
//        likeBadgeView?.setOnClickListener { onLikeClick() }
//        tvLetmeSay?.setOnClickListener { onLetMeSayClick() }
//
//        initBottomBack()
//        initCollect()
//        initShare()
//        initCommentButton()
//        initLikeButton()
//        initLetmeSay()
//        orderView()
//    }
//
//    //是否打开顶栏设置，默认情况下是关闭的
//    fun openTitleBarSetting(): Boolean {
//        return false
//    }
//
//    private fun toggleTitleBar(open: Boolean) {
//        if (open == titleBarIsOpen) {
//            return
//        }
//        titleBarIsOpen = open
//        if (textSizeCtl != null) textSizeCtl.visibility = View.GONE
//        showView(open, mTitileBar)
//    }
//
//    /**
//     * 如果直接放在layout的布局中
//     */
//    private fun initBottomView() {
//
//    }
//
//    /**
//     * 对底部的View进行重新布局
//     */
//    fun layoutBottomView(laymeSayShow: Boolean) {
//        if (laymeSayShow) { //显示评论框,几个按钮以wrap_content占据整个布局
//            var linearLayout = findViewById<LinearLayout>(R.id.linear_comment_layout)
//            var params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = ViewGroup.LayoutParams.WRAP_CONTENT
//            params.weight = 1f
//            linearLayout.layoutParams = params
//            linearLayout = findViewById(R.id.linear_like_layout)
//            params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = ViewGroup.LayoutParams.WRAP_CONTENT
//            params.weight = 1f
//            linearLayout.layoutParams = params
//            linearLayout = findViewById(R.id.linear_collect_layout)
//            params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = ViewGroup.LayoutParams.WRAP_CONTENT
//            params.weight = 1f
//            linearLayout.layoutParams = params
//            linearLayout = findViewById(R.id.linear_share_layout)
//            params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = ViewGroup.LayoutParams.WRAP_CONTENT
//            params.weight = 1f
//            linearLayout.layoutParams = params
//        } else {
//            var linearLayout = findViewById<LinearLayout>(R.id.linear_comment_layout)
//            var params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = 0
//            params.weight = 1f
//            linearLayout.layoutParams = params
//            linearLayout = findViewById(R.id.linear_like_layout)
//            params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = 0
//            params.weight = 1f
//            linearLayout.layoutParams = params
//            linearLayout = findViewById(R.id.linear_collect_layout)
//            params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = 0
//            params.weight = 1f
//            linearLayout.layoutParams = params
//            linearLayout = findViewById(R.id.linear_share_layout)
//            params = linearLayout.layoutParams as LinearLayout.LayoutParams
//            params.width = 0
//            params.weight = 1f
//            linearLayout.layoutParams = params
//        }
//    }
//
//    /**
//     * 对底部的View进行排序，根据后台的下发顺序显示
//     */
//    fun orderView() {
//        val viewMap = prepareOriginalViewMap()
//        val linkedHashSet = newsDetailStyleConfig!!.linkedHashSet
//        bottomBarLayout!!.removeAllViews()
//        bottomBarLayout!!.addView(bottomBack)
//        for (item in linkedHashSet) {
//            val view = viewMap.remove(item)
//            if (view != null) {
//                bottomBarLayout!!.addView(view)
//            }
//        }
//
//        //本身如果 linkedHashSet 没有对应的值的话,说明后台配置显示可以不用处理，但是有可能会有一些其他的调用处理因此还是添加回去
//        if (!viewMap.isEmpty()) {
//            val entrySet: Set<Map.Entry<String, View?>> = viewMap.entries
//            for ((_, value) in entrySet) {
//                bottomBarLayout!!.addView(value)
//            }
//        }
//    }
//
//    fun prepareOriginalViewMap(): HashMap<String, View?> {
//        val viewMap = HashMap<String, View?>()
//        viewMap[NewsDetailStyleConfig.COLLECT_BUTTON] = findViewById(R.id.linear_collect_layout)
//        viewMap[NewsDetailStyleConfig.SHARE_BUTTON] = findViewById(R.id.linear_share_layout)
//        viewMap[NewsDetailStyleConfig.LIKE_BUTTON] = findViewById(R.id.linear_like_layout)
//        viewMap[NewsDetailStyleConfig.COMMENT_BUTTON] = findViewById(R.id.linear_comment_layout)
//        viewMap[NewsDetailStyleConfig.COMMENT_BOX] = tvLetmeSay
//        return viewMap
//    }
//
//    private fun initLikeButton() {
//
//        likeBadgeView?.setResDiss()
//
//        //用于点赞按钮的点击事件采集
//        likeBadgeView?.setmButtonClickLike(this)
//        showLikeButtonWithConfig(true)
//    }
//
//    private fun initCommentButton() {
//
//        showCommentButtonWithConfig(true)
//    }
//
//    private fun initShare() {
//
//        showShareWithConfig(true)
//    }
//
//    private fun initCollect() {
//
//
//        showCollectWithConfig(true)
//    }
//
//    private fun initBottomBack() {
//        showBottomBack(!titleBarIsOpen)
//    }
//
//    private fun initLetmeSay() {
//
//        showLetMeSayWithConfig(true)
//    }
//
//    /**
//     * 显示底部返回
//     *
//     * @param show true 显示， false 隐藏
//     */
//    fun showBottomBack(show: Boolean) {
//        showView(show, bottomBack)
//    }
//
//    fun showLetMeSayWithConfig(show: Boolean) {
//        var show = show
//        show = newsDetailStyleConfig!!.linkedHashSet.contains(NewsDetailStyleConfig.COMMENT_BOX) && show
//        showView(show, tvLetmeSay)
//        // layoutBottomView(show);
//    }
//
//    fun showCollectWithConfig(show: Boolean) {
//        var show = show
//        show = newsDetailStyleConfig!!.linkedHashSet.contains(NewsDetailStyleConfig.COLLECT_BUTTON) && show
//        showView(show, bottomBarLayout!!.findViewById(R.id.linear_collect_layout))
//    }
//
//    fun showShareWithConfig(show: Boolean) {
//        var show = show
//        show = newsDetailStyleConfig!!.linkedHashSet.contains(NewsDetailStyleConfig.SHARE_BUTTON) && show
//        showView(show, bottomBarLayout!!.findViewById(R.id.linear_share_layout))
//
//        //使用服务器返回的分享按钮
//        GlideUtils.loadUrl(newsDetailStyleConfig!!.getShowIcon().share_button_un_icon
//                , bottomBarLayout!!.findViewById<View>(R.id.image_bottom_share) as ImageView
//                , null, resources.getDrawable(R.drawable.common_share))
//    }
//
//    fun showCommentButtonWithConfig(show: Boolean) {
//        var show = show
//        show = newsDetailStyleConfig!!.linkedHashSet.contains(NewsDetailStyleConfig.COMMENT_BUTTON) && show
//        showView(show, bottomBarLayout!!.findViewById(R.id.linear_comment_layout))
//        //使用服务器返回的评论按钮
//        val badgeView: BadgeView = bottomBarLayout!!.findViewById(R.id.commentBadgeView)
//        GlideUtils.loadUrl(newsDetailStyleConfig!!.getShowIcon().comment_button_un_icon
//                , badgeView.badgeImageView
//                , null, resources.getDrawable(R.drawable.common_comments))
//    }
//
//    fun setCustomIcom() {
//        //移动到对应的地方，这里先不加
//    }
//
//    fun showLikeButtonWithConfig(show: Boolean) {
//        var show = show
//        show = newsDetailStyleConfig!!.linkedHashSet.contains(NewsDetailStyleConfig.LIKE_BUTTON) && show
//        if (show) {
//            if (newsLikePresenter == null) {
//                likeBadgeView!!.setArticleItem(articleItem)
//                newsLikePresenter = NewsLikePresenter(this, likeBadgeView)
//                newsLikePresenter!!.setIsSupport(articleItem.isSupport)
//            }
//        }
//        showView(show, bottomBarLayout!!.findViewById(R.id.linear_like_layout))
//    }
//
//    fun showView(show: Boolean, view: View?) {
//        if (show) {
//            view!!.visibility = View.VISIBLE
//        } else {
//            view!!.visibility = View.GONE
//        }
//    }
//
//    abstract fun onLikeClick()
//    abstract fun onCommentClick()
//    abstract fun onShareClick()
//    abstract fun onCollectClick()
//    abstract fun onLetMeSayClick()
//
//    /**
//     * 展示评论相关的View 评论按钮和评论框
//     *
//     * @param show 根据后台的样式配置 true 展示 false 关闭
//     * 当本条新闻禁止评论的时候，即使后台打开了评论框也不显示。
//     */
//    fun showCommentRelativeView(show: Boolean) {
//        showLetMeSayWithConfig(show)
//        showCommentButtonWithConfig(show)
//    }
//
//    fun isShowComment(articleItem: ArticleItem): Boolean {
//        return "1" == articleItem.isComment
//    }
//
//    override fun onResume() {
//        super.onResume()
//        getLikeStatus(this, articleItem.getId(), newsLikePresenter!!, 1, likeBadgeView!!)
//    }
//
//    override fun finish() {
//        super.finish()
//        if (newsLikePresenter != null) {
//            newsLikePresenter!!.addLikeDataInvoke.destory()
//        }
//    }
//
//    /**
//     * 是否显示点赞控件
//     *
//     * @return
//     */
//    fun showLikeViews(): Boolean {
//        return articleItem != null && articleItem.tagsflag == 1 && AppFactoryGlobalConfig.getAppServerConfigInfo(this).otherFunction != null && AppFactoryGlobalConfig.getAppServerConfigInfo(this).otherFunction.support > 0
//    }
//
//    /**
//     * 设置点赞数
//     *
//     * @param type 点赞类型 1文稿，5爆料，6问政。默认为1
//     */
//    fun setLikeButtonNumb(type: Int) {
//        if (showLikeViews()) {
//            if (newsLikePresenter == null) {
//                likeBadgeView!!.setArticleItem(articleItem)
//                newsLikePresenter = NewsLikePresenter(this, likeBadgeView)
//                newsLikePresenter!!.setIsSupport(articleItem.isSupport)
//            }
//            likeBadgeView!!.setLikeNum(articleItem)
//            newsLikePresenter!!.setIsSupport(articleItem.isSupport)
//            NewsLikePresenter.initLikes(newsLikePresenter!!.addLikeDataInvoke, likeBadgeView, likeBadgeView!!.badgeTextView, articleItem, this, type)
//        }
//    }
//}